<template>
  <div class="query-form">
    <div class="form">
      <slot></slot>
    </div>

    <template v-if="$slots.more">
      <div class="expand" @click="moreSearch">
        <slot name="more">
          <span v-if="expand" class="ns">收起过滤</span>
          <span v-else class="ns">展开过滤</span>
        </slot>
        <el-icon>
          <ArrowUpBold v-if="expand" />
          <ArrowDownBold v-else />
        </el-icon>
      </div>
    </template>

    <template v-if="$slots.footer">
      <div class="footer">
        <slot name="footer"></slot>
      </div>
    </template>
  </div>
</template>

<script setup name="QueryForm">
import { ref } from 'vue'

const expand = ref(true)

function moreSearch() {
  expand.value = !expand.value
}
</script>

<style lang="scss" scoped>
.query-form {
  display: flex;
  flex-direction: column;
  width: 100%;
  position: relative;
  min-height: 50px;
  max-height: 300px;
  background-color: #ffffff;
  box-shadow: var(--el-box-shadow-lighter);
  border-radius: 4px;

  .form {
    display: flex;
    flex: 1;
    padding: 5px 0 0 5px;
  }

  .expand {
    position: absolute;
    top: 0;
    right: 5px;
    display: flex;
    height: 20px;
    cursor: pointer;

    span {
      color: #53a8ff;
      margin-right: 5px;
    }
  }

  .footer {
    display: flex;
    height: 30px;
    align-items: center;
    justify-content: center;
  }
}
</style>
